package my.app.com.taobao.forfun.getqueryresult;

import java.io.UnsupportedEncodingException;

import my.java.io.StringFilter;

public class TaobaoLineConvertor implements StringFilter {
	GetValueOfQuery query = new GetValueOfQuery();

	public String convert(String string) {
		StringBuffer sb = new StringBuffer();
		if (string != null && string.length() != 0) {
		try {
			sb.append(string);
			String mytext = java.net.URLEncoder.encode(string, "gb2312");
			String shopText = string;
			if (string.contains("男 ") || string.contains("女 ")) {
				shopText = string.split(" ")[1];
			}
			shopText = java.net.URLEncoder.encode(shopText, "gb2312");
			sb.append("\t" + query.getValeuOfQuery("http://s.taobao.com/search?q={product}", mytext, "找到相关宝贝<em>", "</em>件</div>"));
			sb.append("\t" + query.getValeuOfQuery("http://s.taobao.com/search?q={product}&tab=mall", mytext, "找到相关宝贝<em>", "</em>件</div>"));
			sb.append("\t" + query.getValeuOfQuery("http://shopsearch.taobao.com/browse/shop_search.htm?shopf=newsearch&q={product}&tag=tag&tab=4&s=0", shopText, "所有店铺(", ")"));
			sb.append("\t" + query.getValeuOfQuery("http://shopsearch.taobao.com/browse/shop_search.htm?shopf=newsearch&stat=5&cattype=1&q={product}&cat=&catName=%CB%F9%D3%D0%C0%E0%C4%BF&rootCat=&tag=tag&filterShopType1=1&tab=4", shopText, "所有店铺(", ")"));
			sb.append("\t" + query.getValeuOfQuery("http://search.china.alibaba.com/selloffer/offer_search.htm?keywords={product}&categoryId=&pageSize=40&country=&province=&showProvince=&city=&sortType=&descendOrder=&onlineStatus=&isOnlyAlipay=&biztype=2&memberlevel=&pmType=&feature=&postTime=&showStyle=img&priceStart=&priceEnd=&quantityBegin=&tradeType=&isCreditFlag=&creditBalance=&filtExcludeKeywords=&partFeature=&filtResultkeywords=&uniqfield=userid&companyName=&memberId=&spuId=&fromOfferId=&spuCategoryId=&entrance=&sprId=&imageFeatures=&defaultMerge=&retailWholesale=&mixWholesale=&isPop=&isRealPrice=&filt=y&lessThanQuantityBegin=true&n=y#listViewBar", mytext, "已合并成<em>", "<"));
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		} 
		}
		return sb.toString();
		
	}

}
